import {Base} from '../../utils/base.js';
class Address extends Base{
  constructor()
  {
    super();
  }

  //添加地址
  addAddress(data,callback)
  {
    var that = this;
    var params = {
      url:'address/add',
      type:'POST',
      data:data,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params)
  }

  //获取用户的地址
  getUserAddress(uid,callback)
  {
    var that = this;
    var params = {
      url:'address/user?uid='+uid,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //把地址设为默认
  setDefaultAddress(id,callback)
  {
    var that = this;
    var params = {
      url:'address/default?id='+id,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params);
  }

  //修改地址
  editAddress(data,callback)
  {
    var that = this;
    var params = {
      url:'address/edit',
      type:'POST',
      data:data,
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params)
  }

  //删除地址
  deleteAddress(id,callback)
  {
    var that = this;
    var params = {
      url:'address/delete?id='+id,
      type:'DELETE',
      sCallback:function(data)
      {
        callback && callback(data);
      }
    };
    this.request(params)
  }
}
export {Address};